import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module';
import { AllExceptionFilter } from './filters/any-exception.filter';
import { SwaggerModule, DocumentBuilder } from '@nestjs/swagger';

async function bootstrap() {
    const app = await NestFactory.create(AppModule);
    app.useGlobalFilters(new AllExceptionFilter); //全局范围的过滤器， 重复使用也只会调用一次
    /**
 * 全局注册中间件
 * const app = await NestFactory.create(AppModule)
 * app.use(logger)
 * await app.listen(3000)
 * 
 */
    const options = new DocumentBuilder()
        .setTitle('个人博客')
        .setDescription('The cats API description')
        .setVersion('1.0')
        .addTag('cats')
        .build();
    const document = SwaggerModule.createDocument(app, options);
    SwaggerModule.setup('docs', app, document);

    await app.listen(3000);
}
bootstrap();
